package com.gg.service.impl;

import com.gg.dao.UserDao;
import com.gg.dao.impl.UserDaoImpl;
import com.gg.pojo.User;
import com.gg.service.UserService;

/**
 * UserService接口的实现
 */
public class UserServiceImpl implements UserService {
    //需要操作数据库中User表
    private UserDao userDao = new UserDaoImpl();

    @Override
    public void registUser(User user) {
        userDao.savaUser(user);
    }

    @Override
    public User login(User user) {
        return userDao.queryUserByUsernameAndPassword(user.getUsername(),user.getPassword());
    }

    @Override
    public boolean existUsername(String username) {
        if(userDao.queryUserByUsername(username)==null){
            //等于null查询不到，表示可用
            return false;
        }
        return true;
    }
}
